package com.jt.controller;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@PropertySource("classpath:/properties/redis.properties")
public class RedisController {
    /**
     * 当程序启动时,会自动加载YML配置文件,将数据保存到spring的内部,
     * 之后通过${key}(springel)  -->缩写(spel表达式)
     *
     * 1.通过yml方式赋值
     * */
    @Value("${redis.host}")
    private String host ;
    @Value("${redis.port}")
    private int port ;



    /**2.通过properties赋值*/
    @Value("${redis2.host}")
    private String host2;
    @Value("${redis2.port}")
    private int port2;


    @RequestMapping("/getNode")
    private String getNode(){
        return "YML取值:"+host+":"+port +"\n"
                + "properties取值:"+host2+":"+port2;
    }





}
